﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using HHL_Acc.HHL_DaoAcc.DataBase;
using HHL_Acc.HHL_DaoAcc.DataObject;
using HHL_Acc.HHL_EntityAcc;

namespace HHL_Acc.HHL_DaoAcc.DataObject
{
    class SmiExportDetailsDao : CBaseDao
    {
        public int InsertSmiExportDetail(SmiExportDetails smiExportDetails)
        {
            String sql =
                "INSERT Smi_Export_Details(ExpID,SerialFrom,TicketCode,Qty,Status) VALUES (@ExpID,@SerialFrom,@TicketCode,@Qty,@Status)";
            SqlParameter[] paramsSql = new SqlParameter[5];
            paramsSql[0] = new SqlParameter("@ExpID", smiExportDetails.ExpID);
            paramsSql[1] = new SqlParameter("@SerialFrom", smiExportDetails.SerialFrom);
            paramsSql[2] = new SqlParameter("@TicketCode", smiExportDetails.TicketCode);
            paramsSql[3] = new SqlParameter("@Qty", smiExportDetails.Qty);
            paramsSql[4] = new SqlParameter("@Status", smiExportDetails.Status);
            try
            {
                return ExcuteNoneQuery(sql, paramsSql);
            }
            catch
            {
                return -1;
            }
        }
        public int UpdateSmiExportDetail(SmiExportDetails smiExportDetails)
        {
            String sql =
                "Update Smi_Export_Details set SerialFrom = @SerialFrom,TicketCode = @TicketCode,Qty = @Qty,Status = @Status where ExpId = @ExpID";
            SqlParameter[] paramsSql = new SqlParameter[5];
            paramsSql[0] = new SqlParameter("@ExpID", smiExportDetails.ExpID);
            paramsSql[1] = new SqlParameter("@SerialFrom", smiExportDetails.SerialFrom);
            paramsSql[2] = new SqlParameter("@TicketCode", smiExportDetails.TicketCode);
            paramsSql[3] = new SqlParameter("@Qty", smiExportDetails.Qty);
            paramsSql[4] = new SqlParameter("@Status", smiExportDetails.Status);
            try
            {
                return ExcuteNoneQuery(sql, paramsSql);
            }
            catch
            {
                return -1;
            }
        }
        public int UpdateSmiExportDetailStatus(SmiExportDetails smiExportDetails)
        {
            String sql =
                "Update Smi_Export_Details set Status = @Status where ExpId = @ExpID";
            SqlParameter[] paramsSql = new SqlParameter[2];
            paramsSql[0] = new SqlParameter("@ExpID", smiExportDetails.ExpID);
            paramsSql[1] = new SqlParameter("@Status", smiExportDetails.Status);
            try
            {
                return ExcuteNoneQuery(sql, paramsSql);
            }
            catch
            {
                return -1;
            }
        }
        public int DeleteSmiExportDetailByImpId(String expId)
        {
            String sql = "Delete Smi_Export_Details where ExpId = @ExpID";

            try
            {
                return ExcuteNoneQuery(sql, new SqlParameter("@ExpID", expId));
            }
            catch
            {
                return -1;
            }
        }

    }
}
